#include "FileIO.h"

#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <fstream>

using namespace FileIO;

void FileIO::loadBuildingMap(Model::BuildingMap& map, std::string filename)
{
    std::ifstream fs(filename.c_str());
    boost::archive::xml_iarchive arch(fs);
    arch >> BOOST_SERIALIZATION_NVP(map);
}

void FileIO::saveBuildingMap(Model::BuildingMap& map, std::string filename)
{
    std::ofstream fs(filename.c_str());
    boost::archive::xml_oarchive arch(fs);
    arch << BOOST_SERIALIZATION_NVP(map);
}

void FileIO::loadMesh(Model::Mesh& mesh, std::string filename)
{
    std::ifstream fs(filename.c_str());
    boost::archive::xml_iarchive arch(fs);
    arch >> BOOST_SERIALIZATION_NVP(mesh);
}

void FileIO::saveMesh(Model::Mesh& mesh, std::string filename)
{
    std::ofstream fs(filename.c_str());
    boost::archive::xml_oarchive arch(fs);
    arch << BOOST_SERIALIZATION_NVP(mesh);
}
